{% extends "base.html" %}

{%block title%}Lista wizyt{%endblock%}

{% block content %}
	<div id="content">
		<h2>Lista wizyt</h2>
		<div class="f-l">
			<span class="m-l"><b>Sortuj:</b></span>
			<a href="?sort=asc&item={{param.item}}&page={{param.page}}&year={{param.year}}&month={{param.month}}">Rosnąco</a>
			| <a href="?sort=desc&item={{param.item}}&page={{param.page}}&year={{param.year}}&month={{param.month}}">Malejąco</a>
			<span class="m-l"><b>Wyświetl:</b></span>
			<a href="?item=25&sort={{param.sort}}&page={{param.page}}&year={{param.year}}&month={{param.month}}">25</a>
			| <a href="?item=50&sort={{param.sort}}&page={{param.page}}&year={{param.year}}&month={{param.month}}">50</a>
			| <a href="?item=75&sort={{param.sort}}&page={{param.page}}&year={{param.year}}&month={{param.month}}">75</a>
		</div>
		<form method="POST" action="" class="f-r m-r">
			{% csrf_token %}
			<span><b>Rok:</b></span> {{form.year}}
			<span class="m-l"><b>Miesiąc:</b></span> {{form.month}}
			<button type="submit">Filtruj</button>
		</form>
		<br />
		<br class="clearfix" />
		<table class="results">
			<tr>
				<th>Data wizyty</th>
			    <th>Imię</th>
				<th>Nazwisko</th>
				<th>Wizyta</th>
				<th>Pacjent</th>
			</tr>
			{%for v in archives%}
			<tr>
				<td>{{v.date}}</td>
				<td>{{v.profile.first_name}}</td>
				<td>{{v.profile.last_name}}</td>
				<td><a href="{%url visit-show v.id%}"><img src="{{MEDIA_URL}}/images/info.png" alt="Pokaż" title="Pokaż wizytę: {{v.date}}"/></a></td>
				<td><a href="{%url visit-user v.profile.id%}"><img src="{{MEDIA_URL}}/images/info.png" alt="Pokaż" title="Pokaż wizyty pacjenta: {{v.profile}}"/></a></td>
			</tr>
			{%empty%}
			<tr>
				<td colspan="5">Brak danych</td>
			</tr>
			{%endfor%}
			<tr>
				<td class="ta-c" colspan="5">
					{%if archives.has_previous%}
						<a href="?page={{archives.previous_page_number}}&sort={{param.sort}}&item={{param.item}}&year={{param.year}}&month={{param.month}}">&laquo;</a>
					{%endif%}
					Strona <b>{{archives.number}}</b> z <b>{{archives.paginator.num_pages}}</b>
					{%if archives.has_next%}
						<a href="?page={{archives.next_page_number}}&sort={{param.sort}}&item={{param.item}}&year={{param.year}}&month={{param.month}}">&raquo;</a>
					{%endif%}
				</td>
			</tr>
		</table>
	</div>
{% endblock %}
